package com.dreamchaser.demo_springmvc.controller;

import com.dreamchaser.demo_springmvc.entity.Author;
import org.springframework.web.bind.annotation.*;

/**
 * @author Dreamchaser
 */
//嫌实现Restful风格的api太麻烦了？直接用@RestController注解，轻松支持restful风格的书写
@RestController
//在controller类前加@RequestMapping注解，可以为所有方法映射路径加个前缀，比如/author，它实际的访问路径为/restful/author
@RequestMapping("/restful")
public class TestRestController {
    @GetMapping("/author")
    public Author getAuthor(String name,Integer age){
        return new Author(name,age);
    }
    @PostMapping("/author")
    public boolean addAuthor(String name){
        return true;
    }
    @DeleteMapping("/author")
    public boolean deleteAuthor(String name){
        return true;
    }
    @PutMapping("/author")
    public boolean deleteAuthor(String name,Integer age){
        return true;
    }
}
